/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Principal.java
 *
 * Created on 31/12/2011, 09:31:56 AM
 */
package gui;

import dao.ArticuloDao;
import gui.panel.ArticulosUI;
import gui.panel.clientes.ClientesUIPrincipal;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JPanel;
import pojos.Articulo;

/**
 *
 * @author Usuario
 */
public class Principal extends javax.swing.JFrame {

    /** Creates new form Principal */
    private List<JPanel> paneles = new ArrayList<JPanel>();

    public Principal() {
        initComponents();
        paneles.add(new gui.panel.ArticulosUI(null));

    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jXTaskPaneContainer1 = new org.jdesktop.swingx.JXTaskPaneContainer();
        jXTaskPane2 = new org.jdesktop.swingx.JXTaskPane();
        jXButton8 = new org.jdesktop.swingx.JXButton();
        jXButton9 = new org.jdesktop.swingx.JXButton();
        jXButton10 = new org.jdesktop.swingx.JXButton();
        jXButton11 = new org.jdesktop.swingx.JXButton();
        jXTaskPane3 = new org.jdesktop.swingx.JXTaskPane();
        jXButton12 = new org.jdesktop.swingx.JXButton();
        jXButton13 = new org.jdesktop.swingx.JXButton();
        jXButton14 = new org.jdesktop.swingx.JXButton();
        jXButton15 = new org.jdesktop.swingx.JXButton();
        jXButton16 = new org.jdesktop.swingx.JXButton();
        jXButton17 = new org.jdesktop.swingx.JXButton();
        jXTaskPane4 = new org.jdesktop.swingx.JXTaskPane();
        jXButton18 = new org.jdesktop.swingx.JXButton();
        jXButton19 = new org.jdesktop.swingx.JXButton();
        jXButton20 = new org.jdesktop.swingx.JXButton();
        mainPanel = new javax.swing.JPanel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        addComponentListener(new java.awt.event.ComponentAdapter() {
            public void componentResized(java.awt.event.ComponentEvent evt) {
                formComponentResized(evt);
            }
        });

        jXTaskPane2.setTitle("Parametrización");

        jXButton8.setText("Datos de la empresa");
        jXButton8.setFont(new java.awt.Font("Times New Roman", 0, 14));
        jXButton8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jXButton8ActionPerformed(evt);
            }
        });
        jXTaskPane2.getContentPane().add(jXButton8);

        jXButton9.setText("Clientes");
        jXButton9.setFont(new java.awt.Font("Times New Roman", 0, 14));
        jXButton9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jXButton9ActionPerformed(evt);
            }
        });
        jXTaskPane2.getContentPane().add(jXButton9);

        jXButton10.setText("Proveedores");
        jXButton10.setFont(new java.awt.Font("Times New Roman", 0, 14));
        jXButton10.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jXButton10ActionPerformed(evt);
            }
        });
        jXTaskPane2.getContentPane().add(jXButton10);

        jXButton11.setText("Artículos");
        jXButton11.setFont(new java.awt.Font("Times New Roman", 0, 14));
        jXButton11.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jXButton11ActionPerformed(evt);
            }
        });
        jXTaskPane2.getContentPane().add(jXButton11);

        jXTaskPaneContainer1.add(jXTaskPane2);

        jXTaskPane3.setTitle("Captura de información");

        jXButton12.setText("Datos de la empresa");
        jXButton12.setFont(new java.awt.Font("Times New Roman", 0, 14));
        jXButton12.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jXButton12ActionPerformed(evt);
            }
        });
        jXTaskPane3.getContentPane().add(jXButton12);

        jXButton13.setText("Datos de la empresa");
        jXButton13.setFont(new java.awt.Font("Times New Roman", 0, 14));
        jXButton13.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jXButton13ActionPerformed(evt);
            }
        });
        jXTaskPane3.getContentPane().add(jXButton13);

        jXButton14.setText("Datos de la empresa");
        jXButton14.setFont(new java.awt.Font("Times New Roman", 0, 14));
        jXButton14.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jXButton14ActionPerformed(evt);
            }
        });
        jXTaskPane3.getContentPane().add(jXButton14);

        jXButton15.setText("Datos de la empresa");
        jXButton15.setFont(new java.awt.Font("Times New Roman", 0, 14));
        jXButton15.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jXButton15ActionPerformed(evt);
            }
        });
        jXTaskPane3.getContentPane().add(jXButton15);

        jXButton16.setText("Datos de la empresa");
        jXButton16.setFont(new java.awt.Font("Times New Roman", 0, 14));
        jXButton16.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jXButton16ActionPerformed(evt);
            }
        });
        jXTaskPane3.getContentPane().add(jXButton16);

        jXButton17.setText("Datos de la empresa");
        jXButton17.setFont(new java.awt.Font("Times New Roman", 0, 14));
        jXButton17.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jXButton17ActionPerformed(evt);
            }
        });
        jXTaskPane3.getContentPane().add(jXButton17);

        jXTaskPaneContainer1.add(jXTaskPane3);

        jXTaskPane4.setTitle("Informes");

        jXButton18.setText("Datos de la empresa");
        jXButton18.setFont(new java.awt.Font("Times New Roman", 0, 14));
        jXButton18.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jXButton18ActionPerformed(evt);
            }
        });
        jXTaskPane4.getContentPane().add(jXButton18);

        jXButton19.setText("Datos de la empresa");
        jXButton19.setFont(new java.awt.Font("Times New Roman", 0, 14));
        jXButton19.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jXButton19ActionPerformed(evt);
            }
        });
        jXTaskPane4.getContentPane().add(jXButton19);

        jXButton20.setText("Datos de la empresa");
        jXButton20.setFont(new java.awt.Font("Times New Roman", 0, 14));
        jXButton20.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jXButton20ActionPerformed(evt);
            }
        });
        jXTaskPane4.getContentPane().add(jXButton20);

        jXTaskPaneContainer1.add(jXTaskPane4);

        mainPanel.setPreferredSize(new java.awt.Dimension(720, 630));
        mainPanel.setLayout(new java.awt.GridLayout(1, 0));

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jXTaskPaneContainer1, javax.swing.GroupLayout.PREFERRED_SIZE, 194, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(mainPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 743, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(mainPanel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 654, Short.MAX_VALUE)
                    .addComponent(jXTaskPaneContainer1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 654, Short.MAX_VALUE))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jXButton8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jXButton8ActionPerformed
        // TODO add your handling code here:
        JPanel datEmp = new gui.panel.DatosEmpresaUI();
        datEmp.setName("DatosEmpresa");
        mainPanel.removeAll();
        mainPanel.add(datEmp);
        this.validate();
        datEmp.setVisible(true);

    }//GEN-LAST:event_jXButton8ActionPerformed

    private void jXButton9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jXButton9ActionPerformed
        // TODO add your handling code here:
//        JPanel cliente = new gui.panel.clientes.ClienteUI();
//        cliente.setName("CLientes");
//        mainPanel.removeAll();
//        mainPanel.add(cliente);
//        this.validate();
//        cliente.setVisible(true);

        JPanel clienteP = new ClientesUIPrincipal();
        clienteP.setName("Clientes");
        mainPanel.removeAll();
        mainPanel.add(clienteP);
        this.validate();
        clienteP.setVisible(true);
    }//GEN-LAST:event_jXButton9ActionPerformed

    private void jXButton10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jXButton10ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jXButton10ActionPerformed

    private void jXButton11ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jXButton11ActionPerformed
        Articulo art = null;

        ArticuloDao artDao = new ArticuloDao();
        List<Articulo> arts = artDao.findAll();

        if (!arts.isEmpty()) {
            art = arts.get(0);
        }

        JPanel articUI = new ArticulosUI(art);
        articUI.setName("Articulos");
        mainPanel.removeAll();
        mainPanel.add(articUI);
        this.validate();
        articUI.setVisible(true);

    }//GEN-LAST:event_jXButton11ActionPerformed

    private void jXButton12ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jXButton12ActionPerformed
        // TODO add your handling code here:
        JPanel test = new gui.panel.TablaArticulosUI();
        test.setName("Articulos");
        mainPanel.removeAll();
        mainPanel.add(test);
        this.validate();
        test.setVisible(true);
    }//GEN-LAST:event_jXButton12ActionPerformed

    private void jXButton13ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jXButton13ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jXButton13ActionPerformed

    private void jXButton14ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jXButton14ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jXButton14ActionPerformed

    private void jXButton15ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jXButton15ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jXButton15ActionPerformed

    private void jXButton16ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jXButton16ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jXButton16ActionPerformed

    private void jXButton17ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jXButton17ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jXButton17ActionPerformed

    private void jXButton18ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jXButton18ActionPerformed
        // TODO add your handling code here:}//GEN-LAST:event_jXButton18ActionPerformed
    }
        private void jXButton19ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jXButton19ActionPerformed
            // TODO add your handling code here:
    }//GEN-LAST:event_jXButton19ActionPerformed

    private void jXButton20ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jXButton20ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jXButton20ActionPerformed

    private void formComponentResized(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_formComponentResized
        // TODO add your handling code here:
        System.out.println("Se cambia");

    }//GEN-LAST:event_formComponentResized

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new Principal().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private org.jdesktop.swingx.JXButton jXButton10;
    private org.jdesktop.swingx.JXButton jXButton11;
    private org.jdesktop.swingx.JXButton jXButton12;
    private org.jdesktop.swingx.JXButton jXButton13;
    private org.jdesktop.swingx.JXButton jXButton14;
    private org.jdesktop.swingx.JXButton jXButton15;
    private org.jdesktop.swingx.JXButton jXButton16;
    private org.jdesktop.swingx.JXButton jXButton17;
    private org.jdesktop.swingx.JXButton jXButton18;
    private org.jdesktop.swingx.JXButton jXButton19;
    private org.jdesktop.swingx.JXButton jXButton20;
    private org.jdesktop.swingx.JXButton jXButton8;
    private org.jdesktop.swingx.JXButton jXButton9;
    private org.jdesktop.swingx.JXTaskPane jXTaskPane2;
    private org.jdesktop.swingx.JXTaskPane jXTaskPane3;
    private org.jdesktop.swingx.JXTaskPane jXTaskPane4;
    private org.jdesktop.swingx.JXTaskPaneContainer jXTaskPaneContainer1;
    private javax.swing.JPanel mainPanel;
    // End of variables declaration//GEN-END:variables
}
